<?php
	namespace Common\Logic;
	use Common\Model\SupplierTypeModel;
	class SupplierTypeLogic extends SupplierTypeModel{
		/*
		* Function:		getSupplierTypeList
		* Description:	供应商类型列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getSupplierTypeList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getSupplierTypeFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getSupplierTypeFilter
		* Description:	供应商类型列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getSupplierTypeFilter($filter = ''){
			$conditon = array();
			if(!empty($filter['name'])){
				$conditon['name'] = array('like','%'.$filter['name'].'%');
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getSupplierTypeCount
		* Description:	供应商类型列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getSupplierTypeCount($filter = ''){
			$conditon = $this->getSupplierTypeFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addSupplierType
		* Description:	增加供应商类型
		* @param:		$data array 增加的数组
		*/
		public function addSupplierType($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getSupplierTypeInfo
		* Description:	获取供应商类型信息 by row
		* @param:		$id int ID
		*/
		public function getSupplierTypeInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateSupplierType
		* Description:	更新供应商类型
		* @param:		$data array 更新的数组
		*/
		public function updateSupplierType($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteSupplierType
		* Description:	删除供应商类型
		* @param:		$id int ID
		*/
		public function deleteSupplierType($id){
			return $this->where(array('id'=>$id))->delete();
		}
		
		/*
		* Function:		getSupplierTypeAllList
		* Description:	部门列表
		*/
		public function getSupplierTypeAllList(){
			return $this->where(array('status'=>1))->select();
		}
	}
?>